

	<!-- start: Content -->
	<div class="main ">

		<div class="row">
			<div class="col-lg-12">
				<h3 class="page-header"><i class="fa fa-indent"></i>新闻编辑</h3>

			</div>
		</div>

		<div class="row">
		    <div class="col-md-10">
		        <div class="panel panel-default">
		            <div class="panel-heading">
		                <h2><i class="fa fa-indent red"></i><strong>审核</strong></h2>
		            </div>
					<div class="panel-body">
						<form action="" method="post" enctype="multipart/form-data" class="form-horizontal ">

			                <div class="form-group">
			                    <label class="col-md-2 control-label" for="text-input">新闻标题</label>
			                    <div class="col-md-9">
			                        <input type="text" value="<?php echo $data['title']?>" id="text-input" name="title" class="form-control" placeholder="请输入标题">

			                    </div>
			                </div>
			                <div class="form-group">
			                    <label class="col-md-2 control-label" for="text-input">新闻作者</label>
			                    <div class="col-md-9">
			                        <input type="text" value="<?php echo $data['author']?>" id="text-input" name="author" class="form-control" placeholder="请填写作者">

			                    </div>
			                </div>

							 <div class="form-group">
			                    <label for="select" class="col-md-2 control-label">新闻类型</label>
			                    <div class="col-md-2 sublevel">

			                        <?php foreach($cate as $key=>$v){?>
			                        <select name="cate_id" size="1" class="form-control select_cate" id="select">

			                            <!-- 顶级分类显示判断 -->
										<?php if($v[0]['pid']==0){?>
										<option value="0">顶级分类</option>
										<?php }?>

			                            <?php foreach($v as $k=>$v1){?>
			                                <!-- 上一级只输出一次 -->
											<?php if($k==0 and $v[0]['pid']!=0){?>
											<option value="<?php echo $v1['pid']?>">上一级</option>
											<?php }?>

				                            <option <?php echo ($v1['id']==$key)?'selected':''; ?> value="<?php echo $v1['id']?>"><?php echo $v1['name']?></option>
			                            <?php }?>
			                        </select>
			                        <?php }?>

			                    </div>
			                </div>
			                <div class="form-group">
			                    <label class="col-md-2 control-label" for="textarea-input">新闻内容</label>
			                    <div class="col-md-9">
			                        <textarea id="textarea-input" name="content" rows="9" class="form-control" placeholder="请输入内容"><?php echo $data['content']?></textarea>
			                    </div>
			                </div>



			                <div class="form-group">
			                    <label class="col-md-2 control-label" for="file-multiple-input">上传图片</label>
			                    <div class="col-md-9">
			                        <input type="file" id="file-multiple-input" name="file-multiple-input" multiple>
			                    </div>
			                </div>
							<br>

					</div>
					<div class="panel-footer">
	                    <button type="submit" class="btn btn-sm btn-success"><i class="fa fa-dot-circle-o"></i>提交</button>
                        <button type="reset" class="btn btn-sm btn-danger"><i class="fa fa-ban"></i>重置</button>
	                </div>
	              </form>
		        </div>
		    </div>


		</div><!--/.row-->

	</div>
	<!-- end: Content -->
	<br><br><br>

	<script src="resources/admin/js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript">
		$(function(){
			//绑定值改变事件
			$('.form-group').on('change','.select_cate',function(){


	            //在ajax追加之前把前一次操作的选项的子级删去
	            $(this).nextAll().remove();

                   // alert($(this).find('option:selected').text());
                //如果选中上一级则不需要执行ajax
                if($(this).get(0).selectedIndex==0){
                  return false;
                }

				//获取id的值
	            var id = $(this).val();


	            //通过ajax获取选中项的子级数据
	            $.ajax({
	            	url: 'index.php?c=cate&a=add&admin=1&id='+id,
	            	type: 'get',
	            	dataType: 'json',
	            	success:function(json){
	            		//将程序返回的子级数据显示到页面中
                        var html = '';
	            		html+='<select name="pid" size="1" class="form-control select_cate" id="select">';
                            html += '<option value="'+id+'">上一级</option>';
                            for(i in json){
	                            html+='<option value="'+json[i].id+'">'+json[i].name+'</option>';
                            }
                        html+='</select>';
                        //追加新下拉页
                        $('.sublevel').append(html);

	            	}
	            })

			});

		})
	</script>
